Skip to content

DEV-1125: report BMP390 values as not calibrated when no coefficients exist - #315

Merged
JongChern merged 1 commit into
masterfrom
DEV-1125_bmp390_no_coeffs_npe
Oct 2, 2026
Merged

JongChern merged 1 commit into
masterfrom
DEV-1125_bmp390_no_coeffs_npe

Conversation

@marknolan

@marknolan marknolan commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Fixes DEV-1125.

Defect

CalibDetailsBmp390 keeps its coefficients in a static map keyed by MAC address.

  • parseCalParamByteArray() skips an all-0x00/0xFF block without storing anything.
  • calibratePressureSensorData() then dereferenced the missing entry and threw a NullPointerException.

That aborted a whole SD import whose header carried no BMP390 coefficients, and could do the same to any stream sampled before the 0xA7 coefficient reply. Found while writing DEV-1123's tests (ShimmerResearch/Shimmer-Advance-API#490), which had to use non-zero coefficients to avoid it.

Fix

  • With no coefficients, calibratePressureSensorData() now returns NaN for pressure and temperature instead of throwing.
  • Why not defaults like BMP180/BMP280: those classes fall back to default coefficients, but Bosch publishes none for the BMP390 (its resetToDefaultParameters() is empty). Inventing them would print plausible-looking wrong numbers.
  • Consistency: NaN matches the web SDK, whose compensatePressure returns null without coefficients.

Testing

  • New API_00024_Bmp390MissingCoefficientsTest (5 tests): all-zero block, all-0xFF block and never-parsed sensor each give NaN without throwing; a real trim block still calibrates within the BMP390's range; a later blank block doesn't erase coefficients already parsed.
  • Proof it catches the bug: without the fix, the three missing-coefficient tests fail with the NullPointerException.
  • cd ShimmerDriver && ./gradlew test: 124 tests, 0 failures.

Siblings (CLAUDE.md §4)

🤖 Generated with Claude Code

… exist

CalibDetailsBmp390 keeps its coefficients in a static map keyed by MAC.
parseCalParamByteArray() skips an all-0x00/0xFF block without storing
anything, and calibratePressureSensorData() then dereferenced the missing
entry and threw a NullPointerException - aborting a whole SD import whose
header carried no BMP390 coefficients, and any stream sampled before the
0xA7 reply.

It now returns NaN for pressure and temperature instead. The BMP180 and
BMP280 fall back to default coefficients, but there are no published
defaults for the BMP390, and inventing them would print plausible wrong
numbers; NaN matches the web SDK, which returns null without
coefficients.

API_00024 covers all-zero, all-0xFF and never-parsed blocks, a valid
block still calibrating within range, and a later blank block not
erasing earlier coefficients.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JongChern
JongChern merged commit 44b7030 into master Oct 2, 2026
2 checks passed
@marknolan
marknolan deleted the DEV-1125_bmp390_no_coeffs_npe branch October 2, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants